/**
 * Created by yangfan on 2016/10/14.
 */
define(['config/appregister',"i18n","business/services/utils"],function(app,i18n,utils){
	//专题页 工程资料
	app.filter('hyfilter1',function(){
	    return function(input){
	        var array = input.slice(2,12);
	        return array;
	    }
	});
	app.filter('hyfilter2',function(){
	    return function(input){
	        var array = input.slice(12,22);
	        return array;
	    }
	});		
	app.filter('hyfilter3',function(){
	    return function(input){
	        var array = input.slice(32,42);
	        return array;
	    }
	});
	//专题页  工程e学堂
	app.filter('hyfiltere1',function(){
	    return function(input){
	        var array = input.slice(0,4);
	        return array;
	    }
	});		
	app.filter('hyfiltere2',function(){
	    return function(input){
	        var array = input.slice(4,8);
	        return array;
	    }
	});		
	app.filter('hyfiltere3',function(){
	    return function(input){
	        var array = input.slice(8,12);
	        return array;
	    }
	});	
	app.filter('hyfiltere4',function(){
	    return function(input){
	        var array = input.slice(12,16);
	        return array;
	    }
	});

    app.filter('dataFormat',function(){
        return function(data,num){
            var array =[];
            if(num*4<data.length){
                array.push(data[num*4]);
            }
            if((num*4+1)<data.length){
                array.push(data[num*4+1]);
            }
            if((num*4+1)<data.length){
                array.push(data[num*4+2]);
            }
            if((num*4+1)<data.length){
                array.push(data[num*4+3]);
            }
            return array;
        }
    });
	
	
	
	
	
	
	
   app.filter("dateFilter",function(){
       return function(input){
           if(!input){
               return
           }
           if(typeof input =="string"&&input!=""&& input.indexOf(" ")!=-1){
               var index = input.indexOf(" ");
               var retDate = input.substr(0,index);
               return retDate
           }
       }
   });
    app.filter("mm2Date",function(){
        return function(input){
            input = parseInt(input);
            if(toString.call(input)!= "[object Number]"){
                return
            }
            function fixZero(num,length){
                var str=""+num;
                var len=str.length;
                var s="";
                for(var i=length;i-->len;){
                    s+="0";
                }
                return s+str;
            }
            var dateNum = input;
            var date=new Date(dateNum);
            return date.getFullYear()+"-"+fixZero(date.getMonth()+1,2)+"-"+fixZero(date.getDate(),2)+" "+fixZero(date.getHours(),2)+":"+fixZero(date.getMinutes(),2)+":"+fixZero(date.getSeconds(),2);

        }
    });
    app.filter("mm2YMD",function(){
        return function(input){
            input = parseInt(input);
            if(toString.call(input)!= "[object Number]"){
                return
            }
            function fixZero(num,length){
                var str=""+num;
                var len=str.length;
                var s="";
                for(var i=length;i-->len;){
                    s+="0";
                }
                return s+str;
            }
            var dateNum = input;
            var date=new Date(dateNum);
            return date.getFullYear()+"-"+fixZero(date.getMonth()+1,2)+"-"+fixZero(date.getDate(),2)

        }
    });
    app.filter("getUnit2Kb",function(){
        return function(input){
            if(typeof input =="undefined") return ;
            if(toString.call (input) == '[object Null]'){
                return
            }
            input = parseInt(input);
            var output =  Math.ceil(input/1024) ;
            if(output > 1024){
                output = Math.ceil(output/1024) ;
                return output + 'M'

            }else{
                return  output + "KB"
            }

        }
    });
    app.filter("getAuthStatus",function(){
        return function(input){
            if(typeof input!="number"){
                return
            }
            if(input == 0){
                return "审核中"
            }
            if(input == 1){
                return "已通过"
            }
            if(input ==2){
                return "未通过"
            }
        }
    });
    app.filter("null20",function(){
        return function(input){
           if(input == null){
               return 0
           }else{
               return input
           }
        }
    });
    app.filter("angleBrackets",function(){
        return function(input){
            if(input==null){
                return
            }
            return "<<"+input + ">>";
        }
    });
    app.filter("addSapce",function(){
        return function(input){
            if(input==null){
                return
            }
            return " "+input + " ";
        }
    });
    app.filter("priceFormat",function(){
        return function(input){
            if(input == 0){
                return "免费"
            }else{
                return input
            }
        }
    });

    app.filter("isSolve",function(){
        return function(input){
            if(input ==0){
                return "问答";
            }
            if(input ==1){
                return "回答";
            }
            if(input ==2){
                return "解决";
            }
        }
    });
    app.filter("sloveStyle",function(){
        return function(input){
            if(input ==0){
                return {
                    border:"1px solid red"
                }
            }else if(input ==1){
                return {
                    border:"1px solid red",
                    cursor:"pointer"
                }
            } else if(input ==2){
                return {
                    border:"1px solid #ddd",
                    color:"#ddd",
                }
            }
        }
    });
    app.filter("formateTime",function(){
        return function(input){
            if(typeof input !="string"){
                return
            }
            var oldTime = Date.parse(input);
            var newTime = new Date().getTime();
            var  during = (newTime - oldTime)/1000/60,output;
            if(during<60){
                output = parseInt(during)+"分钟前" ;
            } else{
                during = during/60;
                    if(during<24){
                        output = parseInt(during) + "小时前";
                    }else{
                        during = during/24;
                        if(during<30){
                            output = parseInt(during) + "天前";
                        }else {
                            during = during/30;
                            if(during<12){
                                output = parseInt(during) + "个月前";
                            }else{
                                during = during/12;
                                output = parseInt(during) + "年前";
                            }
                        }
                    }

                }
            return output;
            }
    });
    app.filter("getRightRank",function(){
            function strlen(str) {
                var len = 0;
                var strLen = str.length;
                if(strLen>50){
                    strLen = 50;
                }
                for (var i = 0; i < strLen; i++) {
                    var c = str.charCodeAt(i);
                    //单字节加1
                    if ((c >= 0x0001 && c <= 0x007e) || (0xff60 <= c && c <= 0xff9f)) {
                        len++;
                    }
                    else {
                        len += 2;
                    }
                }
                return len;
            }
        return function(input){
                if(!input) return ;
                input = input.toString();
                var number;
            var l = input.length;
            var blen = 0;
            for(var i=0; i<l; i++) {
                if (input.charCodeAt(i) > 255) {
                    blen ++;
                }
                blen ++;
                if(blen == 60){
                    number = input.substring(0,i).length;
                }
            }
            if(blen >= 60){
                return input.substring(0,number)+"...";
            }else{
                return input ;
            }
          }
        }
    );
    app.filter("getRightHome",function(){
            function strlen(str) {
                var len = 0;
                var strLen = str.length;
                if(strLen>13){
                    strLen = 13;
                }
                for (var i = 0; i < strLen; i++) {
                    var c = str.charCodeAt(i);
                    //单字节加1
                    if ((c >= 0x0001 && c <= 0x007e) || (0xff60 <= c && c <= 0xff9f)) {
                        len++;
                    }
                    else {
                        len += 2;
                    }
                }
                return len;
            }
            return function(input){
                if(!input) return ;
                input = input.toString();
                var number = strlen(input);
                if(number>= 12){
                    return input.substring(0,11)+"...";
                }else{
                    return input ;
                }
            }
        }
    );
      app.filter("getRightComCon",function(){
            function strlen(str) {
                var len = 0;
                var strLen = str.length;
                if(strLen>100){
                    strLen = 100;
                }
                for (var i = 0; i < strLen; i++) {
                    var c = str.charCodeAt(i);
                    //单字节加1
                    if ((c >= 0x0001 && c <= 0x007e) || (0xff60 <= c && c <= 0xff9f)) {
                        len++;
                    }
                    else {
                        len += 2;
                    }
                }
                return len;
            }
            return function(input){
                if(!input) return ;
                input = input.toString();
                var number = strlen(input);
                if(number>= 12){
                    return input.substring(0,100)+"...";
                }else{
                    return input ;
                }
            }
        }
    );
    app.filter("getRightHome1",function(){
            function strlen(str) {
                var len = 0;
                var strLen = str.length;
                if(strLen>12){
                    strLen = 12;
                }
                for (var i = 0; i < strLen; i++) {
                    var c = str.charCodeAt(i);
                    //单字节加1
                    if ((c >= 0x0001 && c <= 0x007e) || (0xff60 <= c && c <= 0xff9f)) {
                        len++;
                    }
                    else {
                        len += 2;
                    }
                }
                return len;
            }
            return function(input){
                if(!input) return ;
                input = input.toString();
                var number = strlen(input);
                if(number>= 12){
                    return input.substring(0,12)+"...";
                }else{
                    return input ;
                }
            }
        }
    );
    app.filter("getRightHome2",function(){
            function strlen(str) {
                var len = 0;
                var strLen = str.length;
                if(strLen>14){
                    strLen = 14;
                }
                for (var i = 0; i < strLen; i++) {
                    var c = str.charCodeAt(i);
                    //单字节加1
                    if ((c >= 0x0001 && c <= 0x007e) || (0xff60 <= c && c <= 0xff9f)) {
                        len++;
                    }
                    else {
                        len += 2;
                    }
                }
                return len;
            }
            return function(input){
                if(!input) return ;
                input = input.toString();
                var number = strlen(input);
                if(number>= 14){
                    return input.substring(0,14)+"...";
                }else{
                    return input ;
                }
            }
        }
    );
    app.filter("getRightHome3",function(){
            function strlen(str) {
                var len = 0;
                var strLen = str.length;
                if(strLen>10){
                    strLen = 10;
                }
                for (var i = 0; i < strLen; i++) {
                    var c = str.charCodeAt(i);
                    //单字节加1
                    if ((c >= 0x0001 && c <= 0x007e) || (0xff60 <= c && c <= 0xff9f)) {
                        len++;
                    }
                    else {
                        len += 2;
                    }
                }
                return len;
            }
            return function(input){
                if(!input) return ;
                input = input.toString();
                var number = strlen(input);
                if(number>= 10){
                    return input.substring(0,10)+"...";
                }else{
                    return input ;
                }
            }
        }
    );
    app.filter("getRightHome5",function(){
            function strlen(str) {
                var len = 0;
                var strLen = str.length;
                if(strLen>20){
                    strLen = 20;
                }
                for (var i = 0; i < strLen; i++) {
                    var c = str.charCodeAt(i);
                    //单字节加1
                    if ((c >= 0x0001 && c <= 0x007e) || (0xff60 <= c && c <= 0xff9f)) {
                        len++;
                    }
                    else {
                        len += 2;
                    }
                }
                return len;
            }
            return function(input){
                if(!input) return ;
                input = input.toString();
                var number = strlen(input);
                if(number>= 20){
                    return input.substring(0,20)+"...";
                }else{
                    return input ;
                }
            }
        }
    );
    app.filter("getRightHome4",function(){
            function strlen(str) {
                var len = 0;
                var strLen = str.length;
                if(strLen>40){
                    strLen = 40;
                }
                for (var i = 0; i < strLen; i++) {
                    var c = str.charCodeAt(i);
                    //单字节加1
                    if ((c >= 0x0001 && c <= 0x007e) || (0xff60 <= c && c <= 0xff9f)) {
                        len++;
                    }
                    else {
                        len += 2;
                    }
                }
                return len;
            }
            return function(input){
                if(!input) return ;
                input = input.toString();
                var number = strlen(input);
                if(number>= 40){
                    return input.substring(0,40)+"...";
                }else{
                    return input ;
                }
            }
        }
    );
    app.filter("getNewsSummary",function(){
            return function(input){
                if(!input) return ;
                input = input.toString();
                var number = input.length;
                if(number>99){
                    return input.substring(0,99)+"...";
                }else{
                    return input ;
                }
            }
        }
    );
    app.filter("getNewsTitle20",function(){
            return function(input){
                if(!input) return ;
                input = input.toString();
                var number = input.length;
                if(number>25){
                    return input.substring(0,25)+"...";
                }else{
                    return input ;
                }
            }
        }
    );
    app.filter("getHotRankColor",function(){
        return function(input){
            if(typeof input!="number" ) return ;
            var color;
            switch (input){
                case 1:
                    color = '#FF0000';
                    break;
                case 2:
                    color = "#FF9C00";
                    break;
                case 3:
                    color = "#F4F453";
                    break;
                case 4:
                    color = "#30D231";
                    break;
                case 5:
                    color = "#4DDBD6";
                    break;
                case 6:
                    color = "#83B5F3";
                    break;
                case 7:
                    color = "#FF77D8";
                    break;
                case 8:
                    color = "#FF8990";
                    break;
            };
            var ret = {
                color:color
            };
            return ret ;


        }
    });
    app.filter("getSelected",function(){
        return function(input){
           var arr = [];
            for(key in input){
                if(toString.call(input[key]) == "[object Object]"){
                    //行业
                    if(key == "jobInIndustryConf" && typeof (input[key])!= "undefined"){
                        if(input.value == ""){
                            return
                        }else{
                            input[key].type = "jobInIndustryConf";
                            arr.push(input[key])
                        }
                        //居住地
                    }else if(key == "jobInRegionIntension"  && typeof (input[key])!= "undefined"){
                        //如果存在实数
                        if(input[key].hasOwnProperty("regionId")){
                            input[key].type = "jobInRegionIntension";
                            arr.push(input[key])
                        }
                        //工作性质
                    }
                    else if(key == "jobInJobConf"  && typeof (input[key])!= "undefined"){
                        //如果存在实数
                        if(input[key].hasOwnProperty("value") && input[key].value!=""){
                            arr.push(input[key])
                        }
                        //工作性质
                    }
                    else  if(key == "workingStyle"&& input[key]!=""){
                        input[key].type = "workType";
                        arr.push(input[key])
                    }//发布时间
                    else  if(key == "releaseTime"){
                        if(input[key].startTime!= "" ||input[key].endTime!= ""){
                            arr.push(input[key])
                        }
                    }
                    else  if(key == "keyWord"){
                        if(input[key].title!= ""){
                            arr.push(input[key])
                        }
                    }
                    else  if(key == "type"){
                            arr.push(input[key])
                    }
                    else{
                        arr.push(input[key])
                    }
                }
            }
            return arr;
        }
    });
    app.filter("formateSelected",function(){
        return function(input){
            if(input == ""){
                return
            }
            if(input.type == "paymentZone"){
                return "薪资:" + input.srName
            }
            if(input.type == "workyear"){
                return "工作经验:" + input.dictName
            }
            if(input.type == "companyType"){
                return "公司规模:" + input.dictName
            }
            if(input.type == "educationBackground"){
                return "教育背景:" + input.dictName
            }
            if(input.type == "jobType"){
                return "公司性质:" + input.dictName
            }
            if(input.type == "workType"){
                return "工作性质:" + input.dictName
            }
            if(input.type == "time"){
                return "时间:" + input.dictName
            }
            if(input.type == "functionsDetailType"){
                return "职能:" + input.dictName
            };
            //if(input.type == "companyGuild"){
            //    return "行业:" + input.dictName
            //};
            if(input.type == "jobInJobConf"){
                if(input.hasOwnProperty("value")){
                    if(toString.call(input.value) == "[object Array]"){
                        var obj = {
                            fdcName:[]
                        };
                       var ret =  utils.getMulti(input.value,obj);
                        return "职能:" + ret.fdcName ;
                    }
                }
            };
            if(input.type == "jobInIndustryConf"){
                   return "行业:" + input.dictName ;
            };
            if(input.type == "keyWord"){
                if(input.title ==""){
                    return
                }else {
                    return "关键词:" + input.title
                }
            };
            if(input.type == "releaseTime"){
                // TODO 待优化
                if(input.startTime == ""&&input.endTime == ""){
                    return
                }else if(input.startTime == ""&&input.endTime != ""){
                    return "时间:" +  input.endTime
                }else if(input.startTime != ""&&input.endTime == ""){
                    return "时间:" +  input.startTime
                }else if(input.startTime != ""&&input.endTime != ""){
                    return "时间:" +  input.startTime + "-" +  input.endTime ;
                }
            };
            if(input.type == "jobInRegionIntension"){
                return "所选城市:"+  input.regionName
            }
            if(input.type == "type"){
                return "搜索类别:"+  input.value.title
            }



        }

    });
    app.filter("dateFilter2",function(){
        return function(input){
            if(typeof ((new Date(input )).getTime()) == "number"){
                input =  (new Date(input )).getTime();
            }
            var oldTime = input;
            var newTime = new Date().getTime();
            var during = (newTime - oldTime)/1000/60,output;
            if(during<60){
                output = Math.ceil(during)+"分钟前" ;
            } else{
                during = during/60;
                    if(during<24){
                        output = Math.ceil(during) + "小时前";
                    }else{
                        during = during/24;
                        if(during<30){
                            output = Math.ceil(during) + "天前";
                        } else if(during <365) {
                            during = during/30;
                            output = Math.ceil(during) + "月前";
                        }else if(during>365){
                            during = during/365;
                            output = Math.ceil(during) + "年前";
                        }
                    }
                }
            return output;
            }
    });

    app.filter("reSex",function(){
        return function(input){
            if( typeof parseInt(input)!="number"){
                return
            }
            if(parseInt(input) == 0){
                return "男"
            }
            if(parseInt(input) == 1){
                return "女"
            }
        }
    });
    app.filter("getYear",function(){
        return function(time){
            if(typeof time != "string" ){
                return
            }
            var oldYear = parseInt(time.substr(0,time.indexOf("-")));
            var thisYear = parseInt(new Date().getFullYear());
            return thisYear - oldYear
        }
    });
    app.filter("getPlace",function(){
        return function(input){
            if(toString.call(input) != '[object Object]' ){
                return
            }
            if(!input.region){
                return
            }
            return input.region.regionName + " " + input.area.areaName
        }
    });
    app.filter("getMarital",function(){
        return function(input){
            var input = parseInt(input);
            if(toString.call(input) != '[object Number]' ){
                return
            }
            if(input == 0){
                return "已婚"
            }else if(input == 1){
                return "未婚"
            }else if (input == 2){
                return "离异"
            }
        }
    });
    app.filter("getCard",function(){
        return function(input){
            if(toString.call(input) != '[object Object]' ){
                return
            }
            if(input.cardId ==1){
                return input.cardNumber
            }
        }
    });
    app.filter("getLan",function(){
        return function(input){
            if(toString.call(input) != '[object Object]' ){
                return
            }
            return input.laug.name+ "-"+ input.lgrade.name
        }
    });
    app.filter("getIntentionRegion",function(){
        return function(input){
            if(toString.call(input) != '[object Array]' ){
                return
            }
            var arr = [] ;
            input.forEach(function(item ,index,array){
               var  str = item.ewpRegionObject.regionName // + "" + item.ewpAreaObject.areaName;
                arr.push(str)
            })
            return arr.join(" ");
        }
    });
    app.filter("getJobConf",function(){
        return function(input){
            if(toString.call(input) != '[object Array]' ){
                return
            }
            var arr = [] ;
            input.forEach(function(item ,index,array){
                arr.push( item.fdcName)
            })
            return arr.join(" ");
        }
    });
    app.filter("getIndustry",function(){
        return function(input){
            if(toString.call(input) != '[object Array]' ){
                return
            }
            var arr = [] ;
            input.forEach(function(item ,index,array){
                arr.push( item.dictName)
            });
            return arr.join(" ");
        }
    });
    app.filter("getTimeFront",function(){
        return function(input){
            if(toString.call(input) != '[object String]' ){
                return
            }
           var str = input.substr(0,input.lastIndexOf("-")) ;
            var ret = str.replace(/-/g,"/");
            return ret
        }
    });
    app.filter("getFullTimeFront",function(){
        return function(input){
            if(toString.call(input) != '[object String]' ){
                return
            }
            var str = input.substr(0,input.indexOf(" ")) ;
            var ret = str.replace(/-/g,"/");
            return ret
        }
    });

    app.filter("getOverseas",function(){
        return function(input){
            if(toString.call(input) != '[object Number]' ){
                return
            }
            if(input == 1){
                return "[海外经历]"
            }
        }
    });
    app.filter("squareBrackets",function(){
        return function(input){
            if(toString.call(input) != '[object String]' ){
                return
            }
           return "["+input +"]"
        }
    });

	app.filter("dayTime",function(){
        return function(input){
            if(typeof input !="string"){
                return
            }
            var output;
            var now = new Date();
            var day = now.getDate();
            var month = now.getMonth();
            var oldTime = input.split(' ')[0].slice(8);
            var oldMonth = input.split(' ')[0].slice(5,7);
            if(oldTime == day && month != oldMonth){
            	output = "今日";
            }else{
            	output = oldTime+"日";
            }     
            return output;
            }
    });
    app.filter("getFormateFileTypeEng",function(){
        return function (typeId){
            if(!typeId) return ;
            if( typeId == 1){
                return "them/imag/doc-center.png"
            }
            if( typeId == 11){
                return "them/imag/pdf-center.png"
            }
            if( typeId == 12){
                return "them/imag/txt-center.png"
            }
            if( typeId == 14){
                return "them/imag/xls-center.png"
            }
            if( typeId == 15){
                return "them/imag/ppt-center.png"
            }
            if( typeId == 16){
                return "them/imag/rar-center.png"
            }
            if( typeId == 17){
                return "them/imag/swf-center.png"
            }
            if( typeId == 2){
                return "them/imag/doc-center.png"
            }
            if( typeId == 18){
                return "them/imag/jpg-center.png"
            }
            if( typeId == 19){
                return "them/imag/chm-center.png"
            }
            if( typeId == 20){
                return "them/imag/dwg-center.png"
            }
            if( typeId == 21){
                return "them/imag/caj-center.png"
            }
            else {
                return  "them/images/compImages/type-other1.png"
            }
            /*if( typeId == 1||typeId ==2){
                return "them/images/compImages/type-doc.png"
            }
            if( typeId == 3){
                return "them/images/compImages/type-ppt.png"
            }
            if( typeId == 4){
                return "them/images/compImages/type-pdf.png"
            }
            if( typeId == 11){
                return "them/images/compImages/type-pdf.png"
            }
            if( typeId == 14){
                return "them/images/compImages/type-xls.png"
            }
            if( typeId == 15){
                return "them/images/compImages/type-ppt.png"
            }
            else {
                return  "them/images/compImages/type-other.png"
            }*/
        };
    });
    app.filter("getBigistFileType",function(){
        return function (typeId){
            if(!typeId) return ;
            if( typeId == 1){
                return "them/imag/doc-big.png"
            }
            if( typeId == 11){
                return "them/imag/pdf-big.png"
            }
            if( typeId == 12){
                return "them/imag/txt-big.png"
            }
            if( typeId == 14){
                return "them/imag/xls-big.png"
            }
            if( typeId == 15){
                return "them/imag/ppt-big.png"
            }
            if( typeId == 16){
                return "them/imag/rar-big.png"
            }
            if( typeId == 17){
                return "them/imag/swf-big.png"
            }
            if( typeId == 2){
                return "them/imag/doc-big.png"
            }
            if( typeId == 18){
                return "them/imag/jpg-big.png"
            }
            if( typeId == 19){
                return "them/imag/chm-big.png"
            }
            if( typeId == 20){
                return "them/imag/dwg-big.png"
            }
            if( typeId == 21){
                return "them/imag/caj-big.png"
            }
            else {
                return  "them/images/compImages/type-other1.png"
            }
            /*if( typeId == 1){
                return "them/images/compImages/type-doc1.png"
            }
            if( typeId == 3){
                return "them/images/compImages/type-ppt1.png"
            }
            if( typeId == 4){
                return "them/images/compImages/type-pdf1.png"
            }
            if( typeId == 11){
                return "them/images/compImages/type-pdf1.png"
            }
            if( typeId == 14){
                return "them/images/compImages/type-xls1.png"
            }
            if( typeId == 15){
                return "them/images/compImages/type-ppt1.png"
            }
            else {
                return  "them/images/compImages/type-other1.png"
            }*/
        };
    });
    app.filter("getFormateFileType",function(){
        return function (typeId){
            if(!typeId) return ;
            if( typeId == 1){
                return "them/imag/doc-small.png"
            }
            if( typeId == 11){
                return "them/imag/pdf-small.png"
            }
            if( typeId == 12){
                return "them/imag/txt-small.png"
            }
            if( typeId == 14){
                return "them/imag/xls-small.png"
            }
            if( typeId == 15){
                return "them/imag/ppt-small.png"
            }
            if( typeId == 16){
                return "them/imag/rar-small.png"
            }
            if( typeId == 17){
                return "them/imag/swf-small.png"
            }
            if( typeId == 2){
                return "them/imag/doc-small.png"
            }
            if( typeId == 18){
                return "them/imag/jpg-small.png"
            }
            if( typeId == 19){
                return "them/imag/chm-small.png"
            }
            if( typeId == 20){
                return "them/imag/dwg-small.png"
            }
            if( typeId == 21){
                return "them/imag/caj-small.png"
            }
            else {
                return  "them/images/compImages/type-other1.png"
            }
            /*if( typeId == 1|| typeId ==2){
                return "them/images/compImages/type-doc.png"
            }
            if( typeId == 4){
                return "them/images/compImages/type-pdf.png"
            }
            if( typeId == 3){
                return "them/images/compImages/type-ppt.png"
            }
            else {
                return  "them/images/compImages/type-other.png"
            }*/
        };
    });
    app.filter("getIconSmall",function(){
        return function (typeId){
            if(!typeId) return ;
            if( typeId == 1){
                return "them/imag/doc-small.png"
            }
            if( typeId == 11){
                return "them/imag/pdf-small.png"
            }
            if( typeId == 12){
                return "them/imag/txt-small.png"
            }
            if( typeId == 14){
                return "them/imag/xls-small.png"
            }
            if( typeId == 15){
                return "them/imag/ppt-small.png"
            }
            if( typeId == 16){
                return "them/imag/rar-small.png"
            }
            if( typeId == 17){
                return "them/imag/swf-small.png"
            }
            if( typeId == 2){
                return "them/imag/doc-small.png"
            }
            if( typeId == 18){
                return "them/imag/jpg-small.png"
            }
            if( typeId == 19){
                return "them/imag/chm-small.png"
            }
            if( typeId == 20){
                return "them/imag/dwg-small.png"
            }
            if( typeId == 21){
                return "them/imag/caj-small.png"
            }
            else {
                return  "them/images/compImages/type-other1.png"
            }
            /*if( typeId == 1||typeId ==2){
                return "them/images/compImages/icon-doc.png"
            }
            if( typeId == 3){
                return "them/images/compImages/icon-ppt.png"
            }
            if( typeId == 4){
                return "them/images/compImages/icon-pdf.png"
            }
            if( typeId == 11){
                return "them/images/compImages/icon-pdf.png"
            }
            if( typeId == 14){
                return "them/images/compImages/icon-xml.png"
            }
            if( typeId == 15){
                return "them/images/compImages/icon-ppt.png"
            }
            else {
                return  "them/images/compImages/icon-other.png"
            }*/
        };
    });

    //app.filter("getIconSmall",function(){
    //    return function (typeId){
    //        if(!typeId) return ;
    //        if( typeId == 'doc'||typeId ==2){
    //            return "them/images/compImages/icon-doc.png"
    //        }
    //        if( typeId == 3){
    //            return "them/images/compImages/icon-ppt.png"
    //        }
    //        if( typeId == 4){
    //            return "them/images/compImages/icon-pdf.png"
    //        }
    //        if( typeId == 11){
    //            return "them/images/compImages/icon-pdf.png"
    //        }
    //        if( typeId == 14){
    //            return "them/images/compImages/icon-xls.png"
    //        }
    //        if( typeId == 15){
    //            return "them/images/compImages/icon-ppt.png"
    //        }
    //        else {
    //            return  "them/images/compImages/icon-other.png"
    //        }
    //    };
    //});

    app.filter("typeFilter",function(){
        return function (value){
            if(!value) return ;
            if(value == 'pdf'){
                return 'them/images/compImages/logo-pdf.png'
            }
            if(value == 'dwg'){
                return 'them/images/compImages/logo-dwg.png'
            }

        };
    });
    //tagList name字段不为空
    app.filter("TagNotNull",function(){
        return function (tagList){
            if(toString.call(tagList) != '[object Array]' ){
                return
            }
            var arr = [] ;
            tagList.forEach(function(item){
                if(toString.call(item.name) != '[object Null]' && toString.call(item.name) != '[object Undefined]'){
                    arr.push(item)
                }
            })
            return arr ;
        }
    });
    app.filter("getLabelStyle",function(){
        return function (index){
           if(index == 0){
               return {
                   "border": "1px solid #97b7ea "
               }
           }else {
               return {
                   "border": "1px solid #ddd"
               }
           }
        }
    });
    app.filter("addTrim",function(){
    	return function(input){
    		input = input + "";
    		var output = input.replace(/-/,"- ");
    		return output;
    	}
    })
    app.filter("excludeNull",function(){
        return function (input){
            if(!input.name){
                return {
                    display:"none"
                }
            }
        }
    })
    app.filter('getEvaluteTime',function(){
        return function(input){
            function fixZero(num,length){
                var str=""+num;
                var len=str.length;
                var s="";
                for(var i=length;i-->len;){
                    s+="0";
                }
                return s+str;
            }
                input = input + '';
            // 没有 -  默认表示不是标准时间 是毫秒
            if(input.indexOf('-')<0){
                input = parseInt(input) ;
                var dateNum = input;
                var date=new Date(dateNum);
                return date.getFullYear()+"-"+fixZero(date.getMonth()+1,2)+"-"+fixZero(date.getDate(),2);
            }else{
                return input ;
            }
        }
    })
    app.filter('getContentMajor',function(){
        return function(input){
            if(toString.call(input)!= '[object Array]'){
                return
            }
            var arr = [];
            input.forEach(function(item ,index){
                if(item.dcType == 1 || item.dcType == 4 || item.dcType == 7){
                    arr.push(item)
                }
            })
            return arr
        }
    })
    app.filter('getInterContent',function(){
        return function(input){
            if(toString.call(input)!= '[object Array]'){
                return
            }
            var arr = [];
            input.forEach(function(item ,index){
                if(item.dcType == 2 || item.dcType == 5 || item.dcType == 8){
                    arr.push(item)
                }
            })
            return arr
        }
    })
    app.filter('getInterParten',function(){
        return function(input){
            if(toString.call(input)!= '[object Array]'){
                return
            }
            var arr = [];
            input.forEach(function(item ,index){
                if(item.dcType == 3 || item.dcType == 6 || item.dcType == 9){
                    arr.push(item)
                }
            })
            return arr
        }
    })
    app.filter('getInterNew',function(){
        return function(input){
            if(toString.call(input)!= '[object Array]'){
                return
            }
            var arr = [];
            input.forEach(function(item ,index){
                if(item.dcType == 10){
                    arr.push(item)
                }
            })
            return arr
        }
    })
    app.filter('getCategory',function(){
        return function(item){
            if(!!item.fileId){
                var arr = [];
                angular.forEach(function(item,index,array){
                    if(!!item.dcName){
                        arr.push(item.dcName)
                    }
                });
                return arr[0] ;
            };
            if(!!item.thesisId){
                return item.detailCategory.dcName
            }
        }
    })
    app.filter('isShowLab',function(){
        return function(name){
            if(!name){
                return false
            }else{
              return   true
            }
        }
    })
    app.filter('lengthSplit',function(){
        return function(str){
            if(toString.call(str)!='[object String]'){
                return
            }
            if(str.length>10){
               return  str.substring(0,10)+"...";
            }else{
                return str
            }
        }
    })
    app.filter('lengthSplit34',function(){
        return function(str){
            if(toString.call(str)!='[object String]'){
                return
            }
            if(str.length>34){
                return  str.substring(0,30)+"...";
            }else{
                return str
            }
        }
    })
    app.filter('getDcName',function(){
        return function (arr){
            if(toString.call(arr)!='[object Array]') return  ;
            var   arrTemp = [];
            arr.forEach(function(item){
                if(!!item.dcName){
                    arrTemp.push(item.dcName)
                }
            });
            if(arrTemp.length>0){
                return arrTemp[0];
            }else{
                return
            }

        }
    })
    app.filter('getSolved',function(){
        return function(status){
            if(typeof status != 'number'){
                return
            }
            if(status ==0){
                return '关闭'
            }
            if(status ==1){
                return '解决'
            }
            if(status ==2){
                return '未解决'
            }
        }
    });
    app.filter('getReference',function(){
        var Arr = [];
        return function(reference) {
         if(reference.indexOf('##')<0){
             Arr.push(reference);
             return Arr
         }else{
            Arr = reference.split('##');
             return Arr
         }
        }
    });
    app.filter('delHtmlTag',function(){

        return function(str) {
            if(!!str){
                return str.replace(/<[^>]+>/g,"").replace(/&nbsp;/g,' ').substring(0,280)+"...";;//去掉所有的html标记
            }else{
                return str;
            }
        }
    })
});
